package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.pojo.TbProdAtta;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbProdAttaService;
import com.bwie.service.TbProdInfoService;
import com.bwie.service.TbProdService;
import com.bwie.service.TbTypeService;
import com.bwie.utils.R;
import com.bwie.vo.ProdInfoVo;
import com.bwie.vo.ProdVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 小薛超人
 * @version 1.0
 * @description: TODO
 * @date 2025/7/22 9:41
 */
@RestController
@RequestMapping("/prod/prod")
@Api(tags = "商品列表")
public class ProdController {
    @Autowired
    TbProdService tbProdService;

    @Autowired
    TbTypeService tbTypeService;

    @Autowired
    TbProdAttaService tbProdAttaService;

    @Autowired
    TbProdInfoService tbProdInfoService;

    @PostMapping("/getProdList")
    @ApiOperation(value = "商品列表")
    public R getProdList(@RequestBody ProdVo prodVo){
        return tbProdService.getProdList(prodVo);
    }

    @PostMapping("/getProdInfoList")
    @ApiOperation(value = "商品信息表")
    public R getProdInfoList(){
        return tbProdService.getProdInfoList();
    }

    @PostMapping("/addProdList")
    @ApiOperation(value = "添加商品")
    public R addProdList(@RequestBody @Validated TbProd tbProd){
        return tbProdService.addProdList(tbProd);
    }

    @PostMapping("/getTag")
    @ApiOperation(value = "标签列表")
    public R getTag(){
        return tbProdService.getTag();
    }

    @PostMapping("/getSelectTypeTree")
    @ApiOperation(value = "添加树形下拉框")
    public R getSelectTypeTree(){
        return tbTypeService.getSelectTypeTree();
    }

    @PostMapping("/deleteBatchProd")
    @ApiOperation(value = "批量删除商品")
    public R deleteBatchProd(@RequestBody List<Integer> ids ){
        return tbProdService.deleteBatchProd(ids);
    }

    @PostMapping("/addProdAtta")
    @ApiOperation(value = "添加商品附件")
    public R addProdAtta(@RequestBody TbProdAtta tbProdAtta){
        return tbProdAttaService.addProdAtta(tbProdAtta);
    }

    @PostMapping("/getProdById/{prodId}")
    @ApiOperation(value = "商品明细")
    private R getProdById(@PathVariable("prodId") Integer prodId){
        return tbProdService.getProdById(prodId);
    }

    @PostMapping("/getProdInforList")
    @ApiOperation(value = "商品明细列表")
    private R getProdInforList(@RequestBody ProdInfoVo prodInfoVo){
        return tbProdService.getProdInforList(prodInfoVo);
    }

    @PostMapping("/addProdInfo")
    @ApiOperation(value = "添加商品SKU")
    private R addProdInfo(@RequestBody TbProdInfo tbProdInfo){
        return tbProdService.addProdInfo(tbProdInfo);
    }


}
